﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Client_Server_Interface.Chat
{
    public class ClientMessage
    {
        public string Sender { get; set; }
        public string Receiver { get; set; }
        public string Message { get; set; }
        public DateTime TimeStamp { get; set; }
        public MessageSide Side { get; set; }
        //public MessageType MesType { get; set; }
        public bool IsPrivate { get; set; }
        //public List<AdditionalData> MoreInfo { get; set; }

        public ClientMessage()
        {
            Side = MessageSide.Me;
        }

        public static ClientMessage DeserializeMessage(string jsonString)
        {
            return JsonConvert.DeserializeObject<ClientMessage>(jsonString);
        }

        public string Serialize()
        {
            return JsonConvert.SerializeObject(this);
        }
    }

    public enum MessageSide
    {
        Me,
        You
    }

    public enum MessageType
    {
        Text,
        UserList,
        System
    }

    public static class SystemMessageTypes
    {
        // ReSharper disable InconsistentNaming
        public const string CHECK_HERE = "chk";
        public const string USER_EXIST = "usr_exst";
        // ReSharper restore InconsistentNaming
    }

    public class MessageCollection : ObservableCollection<ClientMessage>
    {
    }

    public class AdditionalData
    {
        public string Parameter { get; set; }
        public string Value { get; set; }
    }
}
